﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace VisaApp
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Menu", // Route name
                "Home/Menu", // URL with parameters
                new { controller = "Home", action = "Menu" },
                new string[] { "VisaApp.Controllers" }// Parameter defaults
            );

            routes.MapRoute(
                "menuDetails", // Route name
                "Thong-tin/{Id}/{name}", // URL with parameters
                new { controller = "Home", action = "menuDetails" },
                new { Id = @"([a-z0-9\.-]+)", name = @"([a-z0-9\.-]+)" },
                new string[] { "VisaApp.Controllers" }// Parameter defaults
            );

            routes.MapRoute(
                "TinOfmenuDetails", // Route name
                "thong-tin-chi-tiet/{name}/{id}", // URL with parameters
                new { controller = "News", action = "TinOfmenuDetails" },
                new { name = @"([a-z0-9\.-]+)", id = @"([a-z0-9\.-]+)" },
                new string[] { "VisaApp.Controllers" }// Parameter defaults
            );

            routes.MapRoute(
                "khuvuvvisa", // Route name
                "vi-sa/khu-vuc/{code}/{name}", // URL with parameters
                new { controller = "Visa", action = "KhuVucDetails" },
                new { code = @"([a-z0-9\.-]+)", name = @"([a-z0-9\.-]+)" },
                new string[] { "VisaApp.Controllers"}// Parameter defaults
            );

            routes.MapRoute(
               "DatNuocDetails", // Route name
               "vi-sa/khu-vuc-{namekhuvuc}/quoc-gia-{quocgia}/{regioncode}/{quocgiaid}", // URL with parameters
               new { controller = "Visa", action = "DatNuocDetails" },
               new { namekhuvuc = @"([a-z0-9\.-]+)", quocgia = @"([a-z0-9\.-]+)", regioncode = @"([a-z0-9\.-]+)", quocgiaid = @"([a-z0-9\.-]+)" },
               new string[] { "VisaApp.Controllers" }// Parameter defaults
           );

            routes.MapRoute(
              "ThongtinhuuichDetilas", // Route name
              "thong-tin-huu-ich/{name}/{id}", // URL with parameters
              new { controller = "News", action = "ThongtinhuuichDetilas" },
              new { name = @"([a-z0-9\.-]+)", id = @"([a-z0-9\.-]+)" },
              new string[] { "VisaApp.Controllers" }// Parameter defaults
          );

            routes.MapRoute(
              "NewsDetails", // Route name
              "tin-tuc/{name}/{id}", // URL with parameters
              new { controller = "News", action = "NewsDetails" },
              new { name = @"([a-z0-9\.-]+)", id = @"([a-z0-9\.-]+)" },
              new string[] { "VisaApp.Controllers" }// Parameter defaults
          );

            routes.MapRoute(
              "CauHoiDetails", // Route name
              "cau-hoi-thuong-gap/{name}/{id}", // URL with parameters
              new { controller = "News", action = "CauHoiDetails" },
              new { name = @"([a-z0-9\.-]+)", id = @"([a-z0-9\.-]+)" },
              new string[] { "VisaApp.Controllers" }// Parameter defaults
          );

            routes.MapRoute(
              "TuyenDungDetails", // Route name
              "tuyen-dung/{name}/{id}", // URL with parameters
              new { controller = "News", action = "TuyenDungDetails" },
              new { name = @"([a-z0-9\.-]+)", id = @"([a-z0-9\.-]+)" },
              new string[] { "VisaApp.Controllers" }// Parameter defaults
          );

            routes.MapRoute(
                "Tuvanvisa", // Route name
                "tu-van-visa", // URL with parameters
                new { controller = "Home", action = "Tuvanvisa" } // Parameter defaults
            );

            routes.MapRoute(
                "Gioithieu", // Route name
                "gioi-thieu", // URL with parameters
                new { controller = "Home", action = "Gioithieu" } // Parameter defaults
            );

            routes.MapRoute(
                "Thongtinhuuich", // Route name
                "thong-tin-huu-ich", // URL with parameters
                new { controller = "Home", action = "Thongtinhuuich" } // Parameter defaults
            );

            routes.MapRoute(
                "Cauhoithuonggap", // Route name
                "cau-hoi-thuong-gap", // URL with parameters
                new { controller = "Home", action = "Cauhoithuonggap" } // Parameter defaults
            );

            routes.MapRoute(
                "Tintuc", // Route name
                "tin-tuc", // URL with parameters
                new { controller = "Home", action = "Tintuc" } // Parameter defaults
            );

            routes.MapRoute(
                "Ykienkhachang", // Route name
                "y-kien-khach-hang", // URL with parameters
                new { controller = "Home", action = "Ykienkhachang" } // Parameter defaults
            );

            routes.MapRoute(
                "Thuvien", // Route name
                "thu-vien", // URL with parameters
                new { controller = "Home", action = "Thuvien" } // Parameter defaults
            );

            routes.MapRoute(
                "TuyenDung", // Route name
                "tuyen-dung", // URL with parameters
                new { controller = "Home", action = "TuyenDung" } // Parameter defaults
            );

            routes.MapRoute(
                "Quancao", // Route name
                "quang-cao", // URL with parameters
                new { controller = "Home", action = "Quancao" } // Parameter defaults
            );

            routes.MapRoute(
                "VisaCapCha", // Route name
                "Captcha/Show", // URL with parameters
                new { controller = "Captcha", action = "Show" } // Parameter defaults
            );

            routes.MapRoute(
                "GetAllQuocGia", // Route name
                "Visa/AllQuocGiaByCateid/{code}", // URL with parameters
                new { controller = "Visa", action = "AllQuocGiaByCateid" },
               new { code = @"([a-z0-9\.-]+)" },
                new string[] { "VisaApp.Controllers" }// Parameter defaults
            );

            routes.MapRoute(
              "Default", // Route name
              "{controller}/{action}/{id}", // URL with parameters
              new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
          );


        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
    }
}